<template>
	<view class="steps">
		<view class="steps-title">
			工单流程
		</view>
		<u-steps direction="column" :current="active">
			<u-steps-item :title="item.taskName" v-for="(item,index) in approvalRecordDtoList" :key="index">

				<text class="slot-icon" slot="icon">
					<template v-if="item.statusStr === '已完成'">
						<u-icon name="checkmark-circle" color="#2979ff" size="48rpx"></u-icon>
					</template>
					<template v-else-if="item.statusStr === '已驳回'">
						<u-icon name="close-circle" color="#FF654E" size="48rpx"></u-icon>
					</template>
					<text :class="active===index?'colorgrey colorblack':'colorgrey'"
						v-else-if="item.statusStr === '待完成'">{{index+1}}</text>
					<text class="color" v-else>{{index+1}}</text>
				</text>
				<template slot="desc">
					<view class="des">
						<template v-if="item.userList && item.userList.length>0">
							<text v-for="(user,uindex) in item.userList" :key="uindex">
								{{user.userName}}
							</text>
						</template>
						{{item.statusStr}} {{item.operateTime}}
					</view>

				</template>
			</u-steps-item>
		</u-steps>


		<!-- 	<u-steps direction="column" current="1" activeIcon="checkmark" inactiveIcon="arrow-right">
			<u-steps-item title="已下单" desc="10:30"></u-steps-item>
			<u-steps-item title="已出库" desc="10:35"></u-steps-item>
			<u-steps-item title="运输中" desc="11:40"></u-steps-item>
		</u-steps> -->
	</view>
</template>

<script>
	export default {
		props: {
			approvalRecordDtoList: {
				type: Array,
				default () {
					return []
				}

			}
		},
		data() {
			return {
				active: 0
			}
		},
		mounted() {
			this.getNumber()
		},
		methods: {
			getNumber() {
				const row = this.approvalRecordDtoList || []
				if (row.length > 0) {
					// const successarr = []
					// row.map((item,index) => {
					// 	if (item.statusStr === '已完成') {
					// 		successarr.push(item.statusStr)
					// 	}

					// })
					let num = 0
					for (let i = 0; i < row.length; i++) {
						if (row[i].statusStr === '待完成') {
							num = i
							console.log(i)
							break;
						}
					}
					// console.log(successarr.length,'successarr.length')
					// if (num !=successarr.length+1){
					// 	this.active =num
					// }
					this.active = num 
					// this.active = successarr.length


				}
			}
		}

	}
</script>

<style scoped lang="scss">
	.steps {
		background: #FFFFFF;
		border-radius: 16rpx;
		padding: 30rpx 18rpx;
		box-sizing: border-box;
		margin-bottom: 10rpx;

		.color {
			background: #3685E6;
			font-size: 28rpx;
			width: 40rpx;
			height: 40rpx;
			border-radius: 50%;
			text-align: center;
			line-height: 40rpx;
			display: inline-block;
			color: #fff;
		}

		.colorgrey {
			border: 1rpx solid #CACDD4;
			font-size: 28rpx;
			width: 40rpx;
			height: 40rpx;
			border-radius: 50%;
			text-align: center;
			line-height: 40rpx;
			display: inline-block;
			color: #CACDD4;


		}

		.colorblack {
			color: #000;
			border: 1rpx solid #000;
		}

		.des {
			font-size: 28rpx;

			text {
				margin-right: 10rpx;
			}
		}

		.steps-title {
			font-size: 28rpx;
			font-weight: 500;
			color: #323232;
			margin-bottom: 25rpx;
		}
	}

	::v-deep .u-text__value {
		font-size: 30rpx !important;
		font-weight: 500;
	}

	.des {
		padding: 10px 0 20px 0;
	}
</style>
